//
//  ILAliVideoView.h
//  IMIHome
//
//  Created by 严敏 on 2020/9/27.
//  Copyright © 2020 上海创米科技有限公司. All rights reserved.
//  RN播放器使用

#import <UIKit/UIKit.h>
#import "ILVideoViewProtocol.h"
#import "ILVideoEnum.h"
#import "ILPlayerProtocol.h"

NS_ASSUME_NONNULL_BEGIN

#pragma mark - 统一回调返回数据
typedef void (^OnVideoViewChangeBlock)(NSInteger code,NSDictionary *extra);   //播放器各种触发回调,统一模式
typedef void (^OnVideoChangeBlock)(NSDictionary *extra);   //播放器各种触发回调,统一模式

#pragma mark - 旧的实时流回调

typedef void (^OnEventChangeBlock1)(ILPlayerEventCode code, NSDictionary *extra);   //播放器各种触发回调
typedef void (^OnErrorChangeBlock1)(ILPlayerErrorCode code);                        //播放器错误回调
typedef void (^OnRecordTimeChangeBlock1)(NSInteger times);                           //录像时间回调
typedef void (^OnVideoViewClickBlock1)(void);                                            //播放器单击事件
typedef void (^OnPlayCompletionBlock1)(void);                                            //播放器单击事件


@interface ILVideoView : UIView <ILVideoViewProtocol>

#pragma mark -最新回调新增

@property(nonatomic, copy) OnVideoViewChangeBlock onRecordTimeChange; //录像时间回调
@property(nonatomic, copy) OnVideoViewChangeBlock onVideoEventChangeBlock; //播放器各种触发回调
@property(nonatomic, copy) OnVideoViewChangeBlock onVideoErrorChangeBlock; //播放器错误回调

#pragma mark - 老版本block 后续弃用不在维护
@property(nonatomic, copy) OnEventChangeBlock1 onEventChangeBlock;           //播放器各种触发回调
@property(nonatomic, copy) OnErrorChangeBlock1 onErrorChangeBlock;           //播放器错误回调
@property(nonatomic, copy) OnRecordTimeChangeBlock1 onRecordTimeChangeBlock; //录像时间回调


@property(nonatomic, copy) OnPlayCompletionBlock1 onPlayCompletionBlock;     //播放器看家回看播放完成事件


@property(nonatomic, copy) OnVideoChangeBlock onVideoScaleChangeBlock; //播放器缩放系数回调
@property(nonatomic, copy) OnVideoViewClickBlock1 onVideoViewClickBlock;     //播放器单击事件
@property(nonatomic, copy, nullable) OnVideoViewClickBlock1 onVideoViewDoubleClickBlock;     //播放器双击击事件

#pragma mark - 旧回调
#pragma mark - RNVideo 三方库专用回掉 start
@property(nonatomic, copy) OnVideoChangeBlock onVideoLoadStart;//播放开始
@property(nonatomic, copy) OnVideoChangeBlock onVideoLoad;//加载中
@property(nonatomic, copy) OnVideoChangeBlock onVideoBuffer;
@property(nonatomic, copy) OnVideoChangeBlock onVideoError;
@property(nonatomic, copy) OnVideoChangeBlock onVideoProgress;
@property(nonatomic, copy) OnVideoChangeBlock onVideoSeek;
@property(nonatomic, copy) OnVideoChangeBlock onVideoEnd;
@property(nonatomic, copy) OnVideoChangeBlock onReadyForDisplay;
@property(nonatomic, copy) OnVideoChangeBlock onPlaybackStalled;
@property(nonatomic, copy) OnVideoChangeBlock onPlaybackResume;
@property(nonatomic, copy) OnVideoChangeBlock onPlaybackRateChange;
#pragma mark - RNVideo 三方库专用回掉 end


#pragma mark - 通用
//是否静音
@property(nonatomic, assign, setter=setMuted:) BOOL muted;
//播放、暂停
@property(nonatomic, assign, setter=setPaused:) BOOL paused;
// 仅适用直播、点播、hls 缩放比
@property(nonatomic, assign, setter=setScaleRatio:) CGFloat scaleRatio;
//设置通话模式
@property(nonatomic, assign) BOOL useSpeakAudioModeLive;
//设置跳转时间
@property(nonatomic, assign, getter=getCurrentTime, setter=setCurrentTime:) float currentTime;
//创米云存储播放器tag，rn桥接
@property (nonatomic, copy) NSNumber *reactTag;
// 仅适用直播、点播、hls 画面显示bug
@property(nonatomic, assign, setter=setAspectRatio:) NSInteger aspectRatio;

#pragma mark - 旧的
@property(nonatomic, copy) NSString *did;
@property(nonatomic, assign) ILPlayerType playerType;//播放器类型
@property(nonatomic, assign) ILRenderType renderType;//渲染类型

@property(nonatomic, assign, getter=isMute, setter=setMute:) BOOL mute;//静音
@property(nonatomic, assign, getter=getPlayerSpeed, setter=setPlayerSpeed:) ILPlayerSpeed playerSpeed; //倍速
@property(nonatomic, assign, readonly, getter=getBitRate) NSInteger bitRate;//码率
 @property(nonatomic, assign, readonly, getter=getPlayerState) ILPlayerState playerState;               // 播放器当前状态
//设置全屏
@property(nonatomic, assign, getter=getFullscreen, setter=setFullscreen:) BOOL fullscreen;
//属性
@property(nonatomic, strong, setter=setSrc:) NSDictionary *src;
/* For sending videoProgress events */
@property(nonatomic, assign, setter=setProgressUpdateInterval:) float progressUpdateInterval;
@property(nonatomic, assign, setter=setControls:) BOOL controls;

/* Keep track of any modifiers, need to be applied after each play */
@property(nonatomic, assign, setter=setVolume:) float volume;
@property(nonatomic, assign, setter=setRate:) float rate;
@property(nonatomic, assign, setter=setRepeat:) BOOL repeat;
@property(nonatomic, assign, setter=setPlayInBackground:) BOOL playInBackground;
@property(nonatomic, assign, setter=setPlayWhenInactive:) BOOL playWhenInactive;
@property(nonatomic, copy, setter=setIgnoreSilentSwitch:) NSString *ignoreSilentSwitch;
@property(nonatomic, copy, setter=setResizeMode:) NSString *resizeMode;

@property(nonatomic, assign, setter=setSeek:) NSDictionary *seek;

- (void)setSeek:(NSDictionary *)info;

#pragma -mark 通用
//初始化
- (instancetype)initWithMinZoom:(BOOL)isMinZoom withILPlayerType:(ILPlayerType)playerType;
// 初始化当前渲染视图类型,一般和 setPlayerType 互斥,用于暂时不需要使用play 的场景
- (instancetype)initWithMinZoom:(BOOL)isMinZoom withRenderType:(ILRenderType)renderType;
 
//设置数据源
- (BOOL)setNewDataSource:(NSDictionary *)dataSource;
//开始录像
- (BOOL)startRecord:(NSString *)filePath;
//停止录像
- (BOOL)stopRecord;
//开启对讲
- (void)startSpeak;
//关闭对讲
- (void)stopSpeak;
//截图
- (UIImage *)videoSnapshot;
//录播暂停播放
- (void)pause;
//录播恢复播放
- (void)restore;
//仅录播、实时流 设置畸变校准，enable=false时 x，y，r无效
- (void)setLensCorrect:(BOOL)enable x:(CGFloat)x y:(CGFloat)y r:(CGFloat)r;
//设置屏幕水平分割模式  renderSplitMode: 参考 ffmpegSDk 下  RenderSplitMode 枚举
- (void)setSplitHorizontalMode:(RenderSplitMode)mode;

//仅实时流
- (void)voiceChange:(int)type;  //变声
//设置录播倍速
- (void)setPlayerSpeed:(ILPlayerSpeed)playerSpeed;
/// 设置log级。  ！！！ 发布正式版本请不要打开debug 否则会自动dump 数据流到手机 消耗用户存储空间！！！！
/// - Parameter logLevel: <#logLevel description#>
- (void)setLogLevel:(ILPlayerLogLevel)logLevel;
/// 设置直播和回看播放器log级。  ！！！ 发布正式版本请不要打开debug 否则会自动dump 数据流到手机 消耗用户存储空间！！！！
/// - Parameter logLevel: <#logLevel description#>
+ (void)setLiveAndVodLogLevel:(ILPlayerLogLevel)logLevel;
#pragma -mark 旧

//弃用,目前播放器内部必须处理renderview,一个参数不够判断
//- (instancetype)initWithMinZoom:(BOOL)isMinZoom;

//设置直播播放源
- (BOOL)setDataSourceFromLive:(NSString *)iotId;

/// 设置直播播放源,如果没有传物模型参数,就获取本地缓存的物模型参数
/// @param iotId iotId
/// @param propertiesParams 物模型参数
- (BOOL)setDataSourceFromLive:(NSString *)iotId propertiesParams:(NSDictionary *)propertiesParams;

//设置云存、报警事件播放源
- (BOOL)setDataSourceFromHls:(NSString *)iotId fileName:(NSString *)fileName seekTime:(NSTimeInterval)seekTime;

//设置回看播放源
- (BOOL)setDataSourceFromVod:(NSString *)iotId startTime:(NSInteger)startTime endTime:(NSInteger)endTime seekTime:(NSInteger)seekTime;
//开始播放
- (void)start;
//停止播放
- (void)stop;
- (BOOL)isMute;
//激活声音
- (void)activePlayer;
//设置静音
- (void)setMute:(BOOL)isMute;
//设置录播进度
- (BOOL)seekTo:(NSTimeInterval)seconds;
//获取录播倍速
- (ILPlayerSpeed)getPlayerSpeed;
//在录制时获取录像时长  -1为没有录制、获取失败等异常
- (NSInteger)getRecordTime;
//获取码率
- (NSInteger)getBitRate;
//获取播放器状态
- (ILPlayerState)getPlayerState;
// 获取当前渲染视图
- (UIView *)getEaglView;

//获取当前播放器实例
- (id<ILPlayerProtocol>)getPlayer;

 - (void)destroy;
//新增 截图并传分辨率参数
- (UIImage *)screenShotWithResolution:(CGFloat)width height:(CGFloat)height;

/// 当前直播模式(仅适用直播)
- (ILPlayerConnectType)getStreamConnectType;
/// 当前直播模式(仅适用直播)-字符串形式
- (NSString *)getStreamConnectTypeDes;

@end

NS_ASSUME_NONNULL_END

